class Solution {
public:
    int row[10][10];
    int col[10][10];
    int pane[3][3][10];
    void solveSudoku(vector<vector<char>>& board)
    {
        int n = 9;
        for (int i = 0; i < 9; i++)
        {
            for (int j = 0; j < 9; j++)
            {
                if (board[i][j] != '.')
                {
                    int x = board[i][j] - '0';
                    row[i][x] = col[j][x] = pane[i / 3][j / 3][x] = 1;
                }
            }
        }
        function<bool()> dfs = [&]() {
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    if (board[i][j] == '.')
                    {
                        for (int x = 1; x <= 9; x++)
                        {
                            if (row[i][x] || col[j][x] || pane[i / 3][j / 3][x]) continue;
                            board[i][j] = x + '0';
                            row[i][x] = col[j][x] = pane[i / 3][j / 3][x] = 1;
                            if (dfs()) return true;
                            board[i][j] = '.';
                            row[i][x] = col[j][x] = pane[i / 3][j / 3][x] = 0;
                        }
                        return false;
                    }
                }
            }
            return true;
            };
        dfs();
    }
};